package com.ruoyi.front.ap.service.impl;

import com.ruoyi.front.ap.pojo.vo.*;
import com.ruoyi.front.ap.mapper.LsdMapper;
import com.ruoyi.front.ap.service.ILsdService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.List;

/**
 * @Author：HuaQP
 * @Date：2023/10/7
 */
@Service
public class LsdServiceImpl implements ILsdService {
    @Resource
    private LsdMapper lsdMapper;

    @Override
    public List<CategoryPlantVo> listPlantCategory(Long year, Long categoryId) {
        return lsdMapper.listPlantCategory(year, categoryId);
    }

    @Override
    public List<CategorySaleVo> listSaleCategory(Long year, Long categoryId) {
        return lsdMapper.listSaleCategory(year, categoryId);
    }

    @Override
    public List<MapPlantVo> listPlantVo(Long year, Long categoryId) {
        return lsdMapper.listPlantVo(year, categoryId);
    }

    @Override
    public List<MapVillageVo> listVillageVo(Long year, Long categoryId) {
        return lsdMapper.listVillageVo(year, categoryId);
    }

    // 获取产品认证列表
    @Override
    public List<CertifiedVo> listCertified() {
        return lsdMapper.listCertified();
    }

    // 获取产品类近5年销售数量情况
    @Override
    public List<CategorySaleVo> listSaleByNearly5Years(Long year) {
        return lsdMapper.listSaleByNearly5Years(year);
    }

    /**
     * 获取各村种植面积
     */
    @Override
    public List<VillagePlantVo> listPlantVillage(Long year) {
        return lsdMapper.listPlantVillage(year);
    }

    /**
     * 获取各村产量 产值
     */
    @Override
    public List<VillageSaleVo> listSaleVillage(Long year) {
        List<VillageSaleVo>  list =  lsdMapper.listSaleVillage(year);
        //聚合查询无记录时会返回 [null]
        list.remove(null);
        return list;
    }

    /**
     * 获取子产品占比情况
     */
    @Override
    public List<ProductSaleVo> listSaleByProduct(Long year, Long categoryId) {
        List<ProductSaleVo>  list =  lsdMapper.listSaleByProduct(year,categoryId);
        //聚合查询无记录时会返回 [null]
        list.remove(null);
        return list;
    }

    /**
     * 获取销售方式情况
     */
    @Override
    public List<SaleWayVo> listByWay(Long year, Long categoryId) {
        List<SaleWayVo>  list =  lsdMapper.listByWay(year,categoryId);
        //聚合查询无记录时会返回 [null]
        list.remove(null);
        return list;
    }

}
